"""
一堆数要尽可能平分成两半
标准的01背包
"""
N = int(input())
W = [int(i) for i in input().split()]
W.insert(0, 0)
Vmax = sum(W)
D = [0 for i in range(Vmax + 1)]
D[0] = 1
for i in range(1, N + 1):
    for j in range(Vmax, W[i] - 1, -1):
        D[j] |= D[j - W[i]]
# for i in D:
#     print(i)
ans = -1
for i in range(Vmax//2, -1, -1):
    if 1 == D[i]:
        ans = i
        break
assert ans != -1
print(ans, Vmax - ans)